#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>

#define DEV_NAME "/dev/buttons"

int main(int argc,char** argv)
{
	int fd;
	unsigned char key_val[4];
	int cnt = 0;

	fd = open(DEV_NAME,O_RDWR);
	if(fd<0)
	{
		printf("can't open\n");
	}
	while(1)
	{
		read(fd,key_val,sizeof(key_val));
		if(!key_val[0] || !key_val[1] ||!key_val[2] ||!key_val[3])
		{
			printf("%4d key pressed:  %d %d %d %d\n",cnt++,key_val[0],key_val[1] ,key_val[2] ,key_val[3]);
		}
	}
	close(fd);

	return 0;

}


